package com.ruoyi.state;

/**
 * @Author syc
 * @Date Created in 17:41 2022/8/18
 * @Description 测试守护线程,
 *  地球守护你
 */
public class TestDaemon {
    public static void main(String[] args) {
        Dq dq = new Dq();
        You you = new You();

        Thread thread = new Thread(dq);
        thread.setDaemon(true); // 默认是false表示是用户线程,正常的线程都是用户线程...
        thread.start(); // 地球守护线程启动
        new Thread(you).start(); // 你 用户线程启动...
    }
}

// 地球
class Dq implements Runnable {
    @Override
    public void run() {
        while(true) {
            System.out.println("地球养育群生");
        }

    }
}

// you
class You implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 26500; i++) {
            System.out.println("你一生都开心的活着");
        }
        System.out.println("========goodbye! world========"); // hello,world
    }
}
